package demo3;

interface IFlying{
    void flying();
}
interface ISwimming{
    void swimming();
}

interface IRunning{
    void running();
}
abstract class Animal{
    public String name;
    public int age;

    public Animal(String name,int age){
        this.name = name;
        this.age = age;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    abstract public void eat();
//        System.out.println("吃饭");

}

class Dog extends Animal implements IRunning,ISwimming{
    public Dog(String name,int age){
        super(name,age);
    }
    @Override
    public void running() {
        System.out.println(this.name+"正在跑");
    }

    @Override
    public void swimming() {
        System.out.println(this.name+"正在游泳");
    }

    @Override
    public void eat() {
        System.out.println("正在吃");
    }
}

class Bird extends Animal implements IFlying{

     public Bird(String name,int age){
         super(name,age);
     }
    @Override
    public void flying() {
        System.out.println(this.name+"正在飞");
    }

    @Override
    public void eat() {
        System.out.println(this.name+"正在吃饭");
    }
}

class Robot implements IRunning{
    @Override
    public void running() {
        System.out.println("机器人正在跑");
    }
}


public class Test3 {
    static void walk(IRunning iRun){
        iRun.running();
    }
public static void eat(Animal animal){
        animal.eat();
}
    public static void main(String[] args) {
        walk(new Dog("小黄",18));
//        walk
        eat(new Bird("催化",18));
        walk(new Robot());
    }
}
